import canvasAbstract from "./canvasAbstract"
import config from "../../config"
import model from "../model/wall"
import wallModel from "../model/wall";

class wall extends canvasAbstract implements ICanvas{
  constructor() {
    super('wall')
  }
  render(): void {
    this.createModels()
    super.renderModels()
  }

  model(): ModelConstructor {
    return model
  }

  num(): number {
    return config.wall.num
  }

  // boss附近的保护砖墙
  protected createModels() {
    const canWidth = config.canvas.width / 2
    const modWidth = config.model.width
    const canHeight = config.canvas.height
    const modHeight = config.model.height
    let pos = [
      {x: canWidth - modWidth, y: canHeight - modHeight},
      {x: canWidth - modWidth, y: canHeight - 2 * modHeight},
      {x: canWidth, y: canHeight - 2 * modHeight},
      {x: canWidth + modWidth, y: canHeight - modHeight},
      {x: canWidth + modWidth, y: canHeight - 2 * modHeight},
    ]
    pos.forEach(position => {
      const model = wallModel
      const instance = new model(position)
      this.models.push(instance)
    })
    // 绘制其他砖墙
    super.createModels()
  }
}

export default new wall()
